package com.pea.fow.controller;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Created by lh on 2017/1/13.
 */

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2).forCodeGeneration(true).select().apis(RequestHandlerSelectors.any())
                //过滤生成链接
                .paths(PathSelectors.regex("/v1/.*")).build().apiInfo(apiInfo());
    }

    private ApiInfo apiInfo() {
        //        ApiInfo apiInfo = new ApiInfo(
        //                "My Project's REST API",
        //                "This is a description of your API.",
        //                "version:1.0",
        //                "API TOS",
        //                "me@wherever.com",
        //                "API License",
        //                "API License URL"
        //        );
        Contact contact=new Contact("李银龙","","颜色项目仅供测试各种技术整合配置使用");
        ApiInfo apiInfo = new ApiInfoBuilder().license("").title("Color v1接口").description("技术配置整合项目").contact(contact).version("1.0").build();

        return apiInfo;
    }

}
